Now we're in our battle royale arena and there's nothing in it.
That's fine.
I'll let you guys decorate this map however you want.
You know, pipes and buildings and cars and stuff that you can hide behind.
But what we need to do is think about the mechanics of when they teleport over.
So we don't want them all going to the same spawn location.
We'll do a control D You might want to spread these out kind of far on the map.
I'm just going to put four here, but they're still going to be chance that they could land together
on the spawn location.
What we should do is give a buffer time like eight seconds or people can run off and they don't have
weapons and they can't attack.
So let's go ahead and work on that right now.
Let's go down to server script service.
Take a look at the game manager, the script that we we copied in.
Now, our game manager actually equips our player, but it uses the equipment manager to do it.
I'm going to scroll down here to this player added, I have two extra spaces.
You probably don't have these spaces here.
We just fix that.
And when the character is added to the game, our equipment manager equips the player.
Let's just get rid of that line of code.
Boom, gone.
But we also did it down here.
Let's get rid of that line of code just in case the character added event didn't fire quick enough.
All right.
Now let's go to our battle manager right here.
Now in our battle manager, we want to require the equipment manager because that's when we want to
put the weapons on our player.
So let's go up near the top line three.
I'll do a local equip, MGR.
We're going to require game dot server script service equipment manager.
Now we can equip them in our battle manager.
And while we're here up at the top, don't forget we're going to have to send messages to some sort
of user interface so people could start see when the battle's starting or if they want things like that.
So let's go ahead and get a variable for replicated storage.
I'll say game get service, replicated storage, and in replicated storage, we're going to have a remote
event, I think we'll call it status R, A status E, We don't have it yet.
We'll do await for child semicolon notice.
We just have weapons here.
Let's fix that.
Let's go to replicated storage, hit the plus, add a remote event.
Let's call that remote event status E Now when we go back here, boom.
So the remote event is the gateway between the server and the client and the client and the server.
So we can send messages to our client and we can get a sound going on the client side.
We can get guys, stuff like that.
Let's go down to lines.
We'll make a function, local function.
I'm just going to call this battle right?
And battle is going to run for the entire battle.
We're going to check statuses, things like that.
But the first thing it's going to do is it count down, give people time to run when they have no weapons.
So we'll say for I equals, we'll make it eight seconds, right?
We could make these variables, we shouldn't use literals, but that's fine.
For now.
We'll say I equals eight, maybe go down to zero and then we're going to go in steps of minus one.
We're going to go eight, seven, six, five four like that do we'll do our one second.
Wait.
And then for now, let's just print this out to the console so we know what's going on.
We'll say battle starting in dot, dot, dot I comma seconds.
Oops, seconds.
There we go.
All right.
When we get down to that point, we're going to equip our player.
So we'll do a for loop for all the players in the game.
And we don't have the players variable.
Let's add the players variable.
Let's go to line six.
Local players equals game.
Get service players.
All right.
Now let's go back down to our battle function and I'll do a for loop for I and V in pairs.
We'll get our players variable right and then we'll do get children to get all the players from the
players variable and it's to the player service.
That's what the variable is for.
Just do this do We're going to get our equipment manager Colon and we'll just do equip player and pass
in the player.
But the player is actually V, right?
So let's put a V there.
There we go.
So this is this I is one, two, three, four.
If you have four players, this V is going to be the player.
All right.
Nice.
So we don't want any weights in there.
We want everybody to get their weapons at approximately the same time.
Then we're going to do a status re to the client.
Nothing's on the client side.
We'll just put this in here as a placeholder and we'll fire all clients and then we're going to send
a message.
We'll just say, Begin now.
We're not calling this battle yet.
We have to do that or it won't work.
Let's go down.
Below the player added event because battle is going to run for the entire duration of the battle.
It doesn't now, but it will.
And we don't want to block our player added event.
The connection to our event handler.
So let's do battle right here and then we'll hit the play button.
We can play it here because we're not actually doing the teleport.
We're just this is where we would be teleporting into the game, right?
So we're here.
Let's go to our View.
Output window.
Here it is.
The printout file starting in.
Oh, look at that.
And then we got our pistol.
When this got down to zero.
That's pretty cool.
So now we have a grace period.
You'd probably want it to be like 30 seconds, right?
But eight seconds is great for a video because you don't want to have to wait that long.